﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EHU_InterfaceProgramming
{
    public class Logger
    {

        private static List<string> log = new List<string>();

        public static event EventHandler LogAdded;
        /// <summary>
        /// Adds a record to the log
        /// </summary>
        /// <param name="message">The message to log</param>
        public static void Log(string message)
        {
            log.Add(message);

            if (LogAdded != null)
                LogAdded(null, EventArgs.Empty);
        }

        /// <summary>
        /// Retrieves the last log from the logger.
        /// </summary>
        /// <returns>the contents of the last log.</returns>
        public static string GetLastLog()
        {
            if (log.Count > 0)
                return log[log.Count - 1];
            else
                return null;
        }

    }
}
